<header>
    <!-- Docs Top Nav -->
    <div class="header-top">
        <div class="container">
            <div class="row">
                <div class="col-xs-6">
                	<?php $currDay = date('d'); $currMonth = date('m'); $currYear = date('Y'); ?>
                    <div class="calendar-header-day">
                        <?php echo CHtml::link(date('d'), array('/Events/categories/dayEvent', 'day'=>$currDay, 'month'=>$currMonth, 'year'=>$currYear), array('title'=>'Sự kiện trong ngày')); ?>
                    </div>
                    <div class="logo">
                        <?php echo CHtml::link('', array('/Home/default/index'), array('title'=>Yii::app()->name)); ?>
                    </div>
                </div>
                <div class="col-xs-6">
<?php $form=$this->beginWidget('CActiveForm', array(
	'id'=>'search-form',
	'action'=>array('/Events/search/index'),
	'enableClientValidation'=>false,
	'clientOptions'=>array(
		'validateOnSubmit'=>true,
	),
	'htmlOptions'=>array(
		'class'=>'header-search'
	),
)); ?>
    <div class="row">
        <div class="col-xs-2">
            <div class="dropdown select text-right">
                <a href="javascript:void(0)" class="dropdown-toggle" data-toggle="dropdown"><span id="SearchForm_label">Tất cả</span> <b class="caret"></b></a>
                <ul class="dropdown-menu">
                    <li><a href="javascript:changeTicket('Tất cả', '')">Tất cả</a></li>
                    <li><a href="javascript:changeTicket('Miễn phí', 'F')">Miễn phí</a></li>
                    <li><a href="javascript:changeTicket('Có phí', 'P')">Có phí</a></li>
                    <li><a href="javascript:changeTicket('Ưu đãi', 'G')">Ưu đãi</a></li>
                </ul>
                <?php echo $form->hiddenField($search, 'ticket'); ?>
                <?php echo $form->hiddenField($search, 'category'); ?>
                <?php echo $form->hiddenField($search, 'start'); ?>
                <?php echo $form->hiddenField($search, 'end'); ?>
                <?php echo $form->hiddenField($search, 'location'); ?>
            </div>
        </div>
        <div class="col-xs-8 form-input">
        	<?php echo $form->textField($search, 'title', array('class'=>'form-control', 'placeholder'=>'Tên sự kiện')); ?>
        </div>
        <div class="col-xs-2 text-right">
            <button type="submit" class="btn btn-default btn-search"><span class="glyphicon glyphicon-search"></span></button>
        </div>
    </div>
<?php $this->endWidget(); ?>
                </div>
            </div>
        </div>
    </div>
    <!-- Docs Main Nav -->
    <div class="navbar navbar-default">
        <div class="container">
            <div class="navbar-header calendar-header-month">
                <button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
                    <span class="icon-bar"></span>
                    <span class="icon-bar"></span>
                    <span class="icon-bar"></span>
                </button>
                <?php echo CHtml::link(date('m-Y'), array('/Events/categories/dayEvent', 'day'=>$currDay, 'month'=>$currMonth, 'year'=>$currYear), array('title'=>'Sự kiện trong ngày')); ?>
            </div>
            <div class="navbar">
                <ul class="nav navbar-nav nav-top">
                    <li class="dropdown">
                        <a href="#" class="dropdown-toggle" data-toggle="dropdown">Địa điểm <b class="caret"></b></a>
                        <ul class="dropdown-menu">
                            <li><?php echo CHtml::link('Hà Nội', array('/Events/categories/locationEvent', 'location'=>'ha-noi')); ?></li>
                            <li><?php echo CHtml::link('Hồ Chí Minh', array('/Events/categories/locationEvent', 'location'=>'ho-chi-minh')); ?></li>
                            <li><?php echo CHtml::link('Đà Nẵng', array('/Events/categories/locationEvent', 'location'=>'da-nang')); ?></li>
                            <li><?php echo CHtml::link('Huế', array('/Events/categories/locationEvent', 'location'=>'hue')); ?></li>
                            <li><?php echo CHtml::link('Nha Trang', array('/Events/categories/locationEvent', 'location'=>'nha-trang')); ?></li>
                        </ul>
                    </li>
                    <li class="divider">|</li>
                    <li class="dropdown">
                        <a href="#" class="dropdown-toggle" data-toggle="dropdown">Danh mục <b class="caret"></b></a>
                        <ul class="dropdown-menu">
                        <?php foreach ($categories as $data) {
                            echo "<li>" . CHtml::link($data->title, array('/Events/categories/view', 'url'=>$data->url), array('title'=>$data->title)) . "</li>";
                        } ?>
                        </ul>
                    </li>
                    <li class="divider">|</li>
                    <li><?php echo CHtml::link('Tin tức', array('/Home/news/index')); ?></li>
                    <li class="divider">|</li>
                    <li><?php echo CHtml::link('Sự kiện Miễn phí', array('/Events/categories/freeEvent')); ?></li>
                </ul>
                <ul class="nav navbar-nav navbar-right">
                    <li>Hot line: <strong>0969.836.599</strong></li>
                    <li class="divider">|</li>
                <?php if (Yii::app()->user->isGuest): ?>
                    <li><?php echo CHtml::link('Đăng nhập', array('/Users/default/login'), array('title'=>'Đăng nhập vào NextTopEvent', 'class'=>'btn-modal', 'data-toggle'=>'modal', 'data-target'=>'#myModal')); ?></li>
                    <li class="divider">|</li>
                    <li><?php echo CHtml::link('Đăng ký', array('/Users/default/authenticate'), array('title'=>'Đăng ký tài khoản tại NextTopEvent')); ?></li>
                    <li><?php echo CHtml::link('Đăng sự kiện <span class="glyphicon glyphicon-circle-arrow-right"></span>', array('/Events/default/create'), array('title'=>'Đăng sự kiện tại NextTopEvent', 'class'=>'btn-create')); ?></li>
                <?php else: ?>
                	<li>Xin chào <strong><?php echo CHtml::link(Yii::app()->user->name, array('/Users/Members/profile/','id'=>Yii::app()->user->id), array('title'=>'Quản lý tài khoản tại NextTopEvent')); ?></strong>
                    &nbsp;(<?php echo CHtml::link('Đăng xuất', array('/Users/default/logout'), array('title'=>'Đăng xuất tài khoản tại NextTopEvent', 'class'=>'btn-logout')); ?>)</li>
                    <li class="divider">&nbsp;</li>
                    <li><?php echo CHtml::link('Đăng sự kiện <span class="glyphicon glyphicon-circle-arrow-right"></span>', array('/Events/default/create'), array('title'=>'Đăng sự kiện tại NextTopEvent', 'class'=>'btn-create')); ?></li>
                <?php endif; ?>
                </ul>
            </div><!--/.nav-collapse -->
        </div>
    </div>
    <!-- Modal -->
    <div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
        <div class="modal-dialog">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                     <h4 class="modal-title">Đăng nhập</h4>
                </div>
                <div class="modal-body">
                </div>
                <div class="modal-footer">
                </div>
            </div>
            <!-- /.modal-content -->
        </div>
        <!-- /.modal-dialog -->
    </div>
    <!-- /.modal -->
    <!-- Modal -->
    <div class="modal fade" id="myModalRecover" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
        <div class="modal-dialog">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                     <h4 class="modal-title">Đăng nhập</h4>
                </div>
                <div class="modal-body">
                </div>
                <div class="modal-footer">
                </div>
            </div>
            <!-- /.modal-content -->
        </div>
        <!-- /.modal-dialog -->
    </div>
    <!-- /.modal -->
<script type="text/javascript">
$(function() {
    $( "#SearchForm_title" ).autocomplete({
        source: function( request, response ) {
			jQuery.ajax({
				url: '<?php echo Yii::app()->createUrl('/Events/request/suggestEvent'); ?>',
				dataType: "json",
				data: {
					title: request.term,
					ticket: $('#SearchForm_ticket').val()
				},
				success: function( data ) {
					response( jQuery.map( data, function( item ) {
						return {
							id: item.id,
							label: item.label,
							value: item.value,
							url: item.url,
							time: item.time,
							image: item.image
						}
					}));
				}
			});
		},
        minLength: 2,
        select: function( event, ui ) {
            $( "#SearchForm_title" ).val(ui.item.value);
            return false;
        }
    }).data( "ui-autocomplete" )._renderItem = function( ul, item ) {
    	return $( "<li class='search-event'></li>" )
	        .append( "<a href='"+item.url+"'><div class='event-left'><img src='"+item.image+"' alt='"+item.label+"' width='80' /></div><div class='event-right'><h3>"+item.label+"</h3><p class='event-time'><span class='glyphicon glyphicon-time'></span> "+item.time+"</p></div></a>")
	        .appendTo( ul );
    }
});
</script>
</header>